import React from 'react'
import PureRenderMixin from 'react-addons-pure-render-mixin'
//头部组件
import HomeHeader from '../../components/HomeHeader/index.jsx';
//轮播组件
import Category from '../../components/Category/index.jsx';
//广告区组件
import Ad from './subpage/Ad.jsx';
//列表组件
import Lists from './subpage/Lists.jsx';
//redux
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux'
class Home extends React.Component {
    constructor(props, context) {
        super(props, context);
        this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
    }
    render() {
        let {cityName} = this.props.userinfo;
        return (
            <div>
                <HomeHeader
                    {...{
                        cityName:cityName
                    }}
                />
                <Category/>
                <div style = {{height:"15px"}}></div>
                <Ad/>
                <div style = {{height:"15px"}}></div>
                <Lists
                    {...{
                        cityName:cityName
                    }}
                />
            </div>
        )
    }
}

//返回组件需要的数据
function mapStateToProps (state) {
        //console.log(state)
              return{
                userinfo:state.userinfo
              } 
        }  
//返回组件需要的绑定好的action
function mapDispatchToProps(dispatch) {
    return{
    }
}
export default connect(mapStateToProps,mapDispatchToProps)(Home)

